import show_toast from '@dfeidao/atom-wxapp/api/interaction/show-toast';
import redirect_to from '@dfeidao/atom-wxapp/api/navigation/redirect-to';
import { IFeidaoAiWeappPage } from '@dfeidao/atom-wxapp/interfaces';
import set_local from '@dfeidao/atom-wxapp/local/set';
import nodejs from '@dfeidao/atom-wxapp/msg/nodejs';
import render from '@dfeidao/atom-wxapp/render/render';
export default async function a001(fd: IFeidaoAiWeappPage) {
	const params = fd.data.params;
	console.log(params);
	const equip_no = params.equip_no;

	set_local(fd, 'equip_no', equip_no);
	// app-supply-merchandise_shelves-find
	const data = await nodejs('app-supply_det/s001', {
		filter: {
			equip_no,
			product_up_status: '已上架'
		},
		asc: ['location_name']
	}) as any;
	console.log(data);

	if (data.length > 0) {
		render(fd, {
			dataArray: data,
			new: true
		});
		set_local(fd, 'data', data);
	} else {
		show_toast('当前门店下无商品', 'none', 1000);
		setTimeout(function () {
			redirect_to('../app-supply_list/app-supply_list');
		}, 1000);

	}
}
